#!/usr/bin/env bash

#Workaround for Unity gnome shell
export UBUNTU_MENUPROXY=0

# Ubuntu overlay scrollbars are not working well with the 1px boundaries in the monodevelop shell
export LIBOVERLAY_SCROLLBAR=0

# The Oxygen GTK theme crashes unless this is set
export OXYGEN_DISABLE_INNER_SHADOWS_HACK=1

# Add our bin/ to LD_LIBRARY_PATH so we can override system libs with bundles
export LD_LIBRARY_PATH="${0%%/bin/monodevelop}/lib/monodevelop/bin/:${LD_LIBRARY_PATH}"

#this script should be in $PREFIX/bin
MONO_EXEC="exec -a monodevelop mono-sgen"
EXE_PATH="${0%%/bin/monodevelop}/lib/monodevelop/bin/MonoDevelop.exe"

_MD_REDIRECT_LOG="${MD_REDIRECT_LOG:-${XDG_CONFIG_HOME:-$HOME/.config}/MonoDevelop/log}"

if [ -n "$_MD_REDIRECT_LOG" ]; then
	mkdir -p `dirname "$_MD_REDIRECT_LOG"`
	$MONO_EXEC $MONO_OPTIONS "$EXE_PATH" $* 2>&1 | tee "$_MD_REDIRECT_LOG"
else
	$MONO_EXEC $MONO_OPTIONS "$EXE_PATH" $*
fi

